<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/vue.js"></script>
    <script src="../js/jquery-3.6.0.js"></script>
</head>
<body>
<!--1. 准备一个容器-->
<div id="app">
    <p>{{fuMsg1}}--------------------{{fuMsg2}}</p>
    <!--不传实际的参数不加括号-->
    <vm-component @zitofu="fun"></vm-component>
</div>

    <template id="temp">
        <!--子传父先创建改变事件-->
        <div>
            {{ziMsg1}}---------------------{{ziMsg2}}
            <button @click="changeValue">点我子传父</button>
        </div>
    </template>
<script>

    const ziComponent = Vue.extend({
        template:"#temp",
        data(){
            return {
                ziMsg1:"子属性1",
                ziMsg2:"子属性2",
            }
        },
        methods:{
            changeValue:function () {
                this.$emit("zitofu",this.ziMsg1,this.ziMsg2);
            }
        }
    });
    // 注册组件
    Vue.component("vm-component",ziComponent);

    let vm = new Vue({
        el: "#app",
        data: {
            fuMsg1: "父属性1",
            fuMsg2: "父属性2",
        },
        methods:{
            fun:function (item1,item2) {
                console.log(item1,item2);
                this.fuMsg1 = item1;
                this.fuMsg2 = item2;
            }
        }
    });
</script>

</body>
</html>